This patch adds a new test that attempts to save and restore a domain
authoremellor@leeni.uk.xensource.com <emellor@leeni.uk.xensource.com>
Wed, 9 Nov 2005 11:39:05 +0000 (12:39 +0100)
committeremellor@leeni.uk.xensource.com <emellor@leeni.uk.xensource.com>
Wed, 9 Nov 2005 11:39:05 +0000 (12:39 +0100)
with a block device attached.  It starts up a domain, mounts a block
device, writes data to it, saves, restores, and then verifies that the
block device can still be read.

Signed-off-by: Dan Smith <danms@us.ibm.com>
tools/xm-test/tests/restore/04_restore_withdevices_pos.py [new file with mode: 0644]
tools/xm-test/tests/restore/Makefile.am

diff --git a/tools/xm-test/tests/restore/04_restore_withdevices_pos.py b/tools/xm-test/tests/restore/04_restore_withdevices_pos.py
new file mode 100644 (file)
index 0000000..4bbecaf
--- /dev/null
@@ -0,0 +1,72 @@
+#!/usr/bin/python
+
+# Copyright (C) International Business Machines Corp., 2005
+# Author: Dan Smith <danms@us.ibm.com>
+
+from XmTestLib import *
+
+domain = XmTestDomain()
+
+domain.configAddDisk("phy:/dev/ram0", "hda1", "w")
+
+s, o = traceCommand("mkfs /dev/ram0")
+if s != 0:
+    FAIL("Unable to mkfs /dev/ram0 in dom0")
+
+try:
+    domain.start()
+except DomainError, e:
+    FAIL(str(e))
+
+try:
+    console = XmConsole(domain.getName())
+    console.sendInput("foo")
+
+    run = console.runCmd("mount /dev/hda1 /mnt")
+    if run["return"] != 0:
+        FAIL("Unable to mount /dev/hda1")
+
+    run = console.runCmd("echo bar > /mnt/foo")
+    if run["return"] != 0:
+        FAIL("Unable to write to block device!")
+
+except ConsoleError, e:
+    FAIL(str(e))
+
+console.closeConsole()
+
+try:
+    s, o = traceCommand("xm save %s /tmp/test.state" % domain.getName(),
+                        timeout=30)
+except TimeoutError, e:
+    FAIL(str(e))
+
+if s != 0:
+    FAIL("xm save exited with %i != 0" % s)
+
+# Let things settle
+time.sleep(15)
+
+try:
+    s, o = traceCommand("xm restore /tmp/test.state",
+                        timeout=30)
+except TimeoutError, e:
+    FAIL(str(e))
+
+if s != 0:
+    FAIL("xm restore exited with %i != 0" % s)
+
+try:
+    console = XmConsole(domain.getName())
+
+    run = console.runCmd("ls | grep proc")
+    if run["return"] != 0:
+        FAIL("ls failed on restored domain")
+    
+    run = console.runCmd("cat /mnt/foo | grep bar")
+    if run["return"] != 0:
+        FAIL("Unable to read from block device")
+
+except ConsoleError, e:
+    FAIL(str(e))
+        
index 0c271a05445258e3d979fbf6ffa105e74befd07d..f690d98fb99c3550afd3c19d6828b76e1c4fca51 100644 (file)
@@ -2,7 +2,8 @@ SUBDIRS =
 
 TESTS = 01_restore_basic_pos.test \
        02_restore_badparm_neg.test \
-       03_restore_badfilename_neg.test
+       03_restore_badfilename_neg.test \
+       04_restore_withdevices_pos.test
 
 XFAIL_TESTS =